home *** CD-ROM | disk | FTP | other *** search
/ Aminet 13 / Aminet 13 - August 1996.iso / Aminet / dev / e / bits.lha / bits / bitstest.e < prev   
Text File  |  1996-06-08  |  2KB  |  40 lines

  1. -> It's only a little example to see the usage of the functions
  2.  
  3. OPT OSVERSION=37
  4.  
  5. MODULE 'tools/bits'
  6.  
  7. PROC main()
  8. DEF a, b, c, str[40]:ARRAY OF CHAR
  9.  
  10.    a:=$10; b:=$11223344; c:=$12345678
  11.  
  12.    WriteF('Initial value for the next tests is $\h.\n',a)
  13.    WriteF('BitSet   : bit 6       = $\h\n', bitset(a, 6))
  14.    WriteF('BitClear : bit 4       = $\h\n', bitclear(a, 4))
  15.    WriteF('BitTest  : bit 3       = $\h\n', bittest(a, 3))
  16.    WriteF('BitTest  : bit 4       = $\h\n', bittest(a, 4))
  17.    WriteF('BitChange: bit 5       = $\h\n', bitchange(a, 5))
  18.    WriteF('BitDSet  : bit 3 dep 1 = $\h\n', bitdset(a, 3, 1))
  19.    WriteF('BitDSet  : bit 3 dep 0 = $\h\n', bitdset(a, 3, 0))
  20.  
  21.    WriteF('\nInitial value for swapping is $11223344.\n')
  22.    WriteF('SWAP_LONG              = $\h\n', swap(b, SWAP_LONG))
  23.    WriteF('SWAP_HIGH              = $\h\n', swap(b, SWAP_HIGH))
  24.    WriteF('SWAP_LOW               = $\h\n', swap(b, SWAP_LOW))
  25.    WriteF('SWAP_INNER             = $\h\n', swap(b, SWAP_INNER))
  26.    WriteF('SWAP_OUTER             = $\h\n', swap(b, SWAP_OUTER))
  27.  
  28.    WriteF('\nInitial value for string functions is $12345678.\n')
  29.    WriteF('BinToStr SIZE_LONG     = %\s\n', bintostr(c, SIZE_LONG, str))
  30.    WriteF('BinToStr SIZE_WORD     = %\s\n', bintostr(c, SIZE_WORD, str))
  31.    WriteF('BinToStr SIZE_BYTE     = %\s\n', bintostr(c, SIZE_BYTE, str))
  32.    WriteF('BinToStr other: 11     = %\s\n', bintostr(c, 11, str))
  33.  
  34.    WriteF('\nInitial string for reconverting into a number is\n  -> ''\s''\n',bintostr(c, SIZE_LONG, str))
  35.    WriteF('StrToBin SIZE_LONG     = $\h\n', strtobin(str, SIZE_LONG))
  36.    WriteF('StrToBin SIZE_WORD     = $\h\n', strtobin(str, SIZE_WORD))
  37.    WriteF('StrToBin SIZE_BYTE     = $\h\n', strtobin(str, SIZE_BYTE))
  38.    WriteF('StrToBin other: 11     = $\h\n', strtobin(str, 11))
  39. ENDPROC
  40.